/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package combomodel.email;

import eloma.classe.email.Email;
import java.util.List;
import javax.swing.AbstractListModel;
import javax.swing.ComboBoxModel;

/**
 *
 * @author icaro
 */
public class ComboBoxEmailModel extends AbstractListModel implements ComboBoxModel {

    private List<Email> listaEmail;
    private Email selection;

    public ComboBoxEmailModel(List<Email> listaEmail) {
        this.listaEmail = listaEmail;
    }

    @Override
    public int getSize() {
        return listaEmail.size();
    }

    @Override
    public Object getElementAt(int index) {
        return listaEmail.get(index);
    }

    @Override
    public void setSelectedItem(Object anItem) {
        selection = (Email) anItem;
    }

    @Override
    public Object getSelectedItem() {
        return selection;
    }

}
